﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;


namespace MMS.Bll
{
    public class AdminManager
    {
       private AdminService AdminService = new AdminService();
       public AdminInfo UserLogin(string username,string userpass)
       {
           return AdminService.Login(username, EncryptWithMD5(userpass));
       }


       /// <summary>
       /// MD5加密
       /// </summary>
       /// <param name="source"></param>
       /// <returns></returns>
       public string EncryptWithMD5(string source)
       {
           byte[] sor = Encoding.UTF8.GetBytes(source);
           MD5 md5 = MD5.Create();
           byte[] result = md5.ComputeHash(sor);
           StringBuilder strbul = new StringBuilder(40);
           for (int i = 0; i < result.Length; i++)
           {
               strbul.Append(result[i].ToString("x2"));//加密结果"x2"结果为32位,"x3"结果为48位,"x4"结果为64位

           }
           return strbul.ToString().ToLower();
       }
        /// <summary>
        /// 使用用户名和密码登录并获取用户信息对象
        /// </summary>
        /// <param name="name"></param>
        /// <param name="pass"></param>
        /// <returns></returns>
    }
}
